package com.sky.mapper;

import com.sky.dto.AbeibeiDTO;
import com.sky.entity.Abeibei;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AbeibeiMapper {

    /**
     * 根据用户id找阿贝贝
     * @param userId
     * @return
     */
    @Select("SELECT a.id, a.name, a.image_url , a.gender, a.create_time FROM abeibei_story.user_abeibei ua JOIN abeibei_story.abeibei a ON ua.abeibei_id = a.id WHERE ua.user_id = #{userId}; ")
    List<Abeibei> getByUserId(Long userId);

    /**
     * 修改阿贝贝
     * @param abeibeiDTO
     */
    void modify(AbeibeiDTO abeibeiDTO);

    /**
     * 新增阿贝贝
     * @param abeibei
     */
    void insert(Abeibei abeibei);

    /**
     * 删除阿贝贝
     * @param id
     */
    @Delete("delete from abeibei_story.abeibei where id=#{id}")
    void delete(Long id);
}
